package com.manager.course;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;


@SuppressWarnings("serial")
public class Course extends Model<Course>{
	
	public static final Course me = new Course();
	
	/**
	 * 所有 sql 与业务逻辑写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
	 */
	public Page<Course> paginate(int pageNumber, int pageSize) {
		return paginate(pageNumber, pageSize, "select c.id, c.course_name, t.id as tid, t.teacher_name ", "from course c left join teacher t on c.tid = t.id order by c.id asc");
	}
	
	public Course findEditById(int id){
		return findFirst("select c.id, c.course_name, t.id as tid, t.teacher_name from course c left join teacher t on c.tid = t.id where c.id = ?" , id);
	}
	
}
